package rd.system.toeicphoto {
	import flash.external.ExternalInterface;
	
	/**
	 * ...
	 * @author cuong.tran@rdsystem.org
	 */
	public class QuestionData {
		/**
		 * <question>        
				<image><![CDATA[P1_41085.jpg]]></image>
				<mp3><![CDATA[P1_41085.mp3]]></mp3>
				<answers>
					<answer right='true'><![CDATA[They have a kite.]]></answer>
					<answer><![CDATA[They have a balloon.]]></answer>
					<answer><![CDATA[They have an airplane.]]></answer>
					<answer><![CDATA[They have a book.]]></answer>
				</answers>        
			</question> 		
		 */
		
		private var strImage	:String;
		private var strMP3		:String;
		private var arrAnswer	:Array;
		private var intRight	:int = 0;
		 
		public function QuestionData(xml:XML) {
			
			strImage = xml.image.toString();
			strMP3 = xml.mp3.toString();
			
			arrAnswer = [];
			for (var i:int = 0; i < xml.answers.answer.length(); i ++) {
				arrAnswer.push(xml.answers.answer[i].toString());
				
				if (xml.answers.answer[i].@right.toString() == 'true') {
					intRight = i;
				}
			}
		}	
		
		public function get image():String {
			return strImage;
		}
		
		public function get mp3():String {
			return strMP3;
		}
		
		public function get right():int {
			return intRight;
		}
		
		public function get answers():Array {
			return arrAnswer;
		}
	}
}